#include "events_filter.hpp"
#include "xftp_task.hpp"
#include <event2/buffer.h>

#include <string>
events_filter::events_filter(/* args */)
{
}

events_filter::~events_filter()
{
}
bufferevent_filter_result events_filter::fileter_out(struct evbuffer *src, struct evbuffer *dst, ev_ssize_t dst_limit,enum bufferevent_flush_mode mode, void *ctx)
{
   
	char data[1024] = {0};
	//读取并清理原数据
    
	int len = evbuffer_remove(src,data,sizeof(data)-1);

	std::string str = "";
	str += "================\n";
	str += data;
	str += "================\n";
	evbuffer_add(dst,str.c_str(),str.size());

	return BEV_OK;
}
bufferevent_filter_result events_filter::fileter_in(struct evbuffer *src, struct evbuffer *dst, ev_ssize_t dst_limit,enum bufferevent_flush_mode mode, void *ctx)
{
	
	char data[1024] = {0};
	//读取并清理原数据
	int len = evbuffer_remove(src,data,sizeof(data)-1);

	//所有字母转成大写
	for (int i = 0; i < len; ++i)
	{
		data[i] = toupper(data[i]);
	}

	evbuffer_add(dst,data,len);
	return BEV_OK;
}
